<template>
  <!-- 选择日期 :placeholder="nowDate"-->
  <div>
    <div class="conditions">
      <span class="title">起始时间</span>
      <Date-picker
        :type="type"
        :editable="false"
        :value="value[0]"
        @on-change="dateAChange"
        style="width: 200px" ref="address"
      ></Date-picker>&#12288;&#12288;
      <span class="title">截止时间</span>
      <Date-picker
        :type="type"
        :editable="false"
        :value="value[1]"
        @on-change="dateBChange"
        style="width: 200px" ref="address1"
      ></Date-picker>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Array,
      default: []
    },
    type: {
      type: String,
      default: "year"
    },
    // 判断是否清空重置
    ishandleClear:{
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
    };
  },
  computed: {},
  watch: {
    ishandleClear(val){
      if(val) {
        // 清空重置
        this.$refs.address.handleClear()
        this.$refs.address1.handleClear()
        this.$emit('ishandleClearFun', false);
      }
    }
  },
  methods: {
    dateAChange(date) {
      this.value[0] = date;
      this.$emit("input", this.value);
    },
    dateBChange(date) {
      this.value[1] = date;
      this.$emit("input", this.value);
    },
  },
  created() {
    console.log(this.value, this.type);
  },
  mounted() {},
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {} // 如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
